﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SocksToggle.Properties;

namespace SocksToggle
{
    public partial class ConfigForm : Form
    {
        bool settingChanged;

        public ConfigForm()
        {
            InitializeComponent();
        }

        private void ConfigForm_Load(object sender, EventArgs e)
        {
            // display settings default
            textUsername.Text = Properties.Settings.Default.UserNameHeader;
            textAuthorization.Text = Properties.Settings.Default.AuthorizationHeader;
            settingChanged = false;
        }

        private void textUsername_TextChanged(object sender, EventArgs e)
        {
            settingChanged = true;
        }

        private void textAuthorization_TextChanged(object sender, EventArgs e)
        {
            settingChanged = true;
        }

        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (settingChanged)
            {
                // set and save settings
                Properties.Settings.Default.UserNameHeader = textUsername.Text;
                Properties.Settings.Default.AuthorizationHeader = textAuthorization.Text;
                Properties.Settings.Default.Save();
                settingChanged = false;
            }
            //close this form
            this.Close();
        }

        private void buttonClose_Click(object sender, EventArgs e)
        {
            //close this form
            this.Close();
        }
    }
}
